package cn.itcast.controller;

import cn.itcast.constant.MessageConstant;
import cn.itcast.entity.Result;
import cn.itcast.service.WxSerivce;
import cn.itcast.vo.OrderInfoVo;
import com.github.wxpay.sdk.WXPay;
import com.github.wxpay.sdk.WXPayRequest;
import com.github.wxpay.sdk.WXPayUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author coolbook
 * @ClassName WXPayController
 * @Description TODO
 * @Date 11:07 2021/11/17
 * @Version 1.0
 */
@RestController
@RequestMapping("pay")
@CrossOrigin
@Slf4j
public class WXPayController {
    @Autowired
    private WxSerivce wxSerivce;

    /**
     * 微信支付生成支付二位码支付链接
     * @param orderId
     * @return
     */
    @GetMapping("wxPay")
    public Result  wxPay(@RequestParam Map<String,String> orderId){
        log.info("订单号码:{}",orderId);
        log.info("预约成功之后前端传递订单编号:{}",orderId);
        String id = orderId.get("orderId");
        String code = this.wxSerivce.createCode(id);
        return new Result(true,"给老子出来",code);
    }
}
